<template>
  <div>

    <catch-table :form-create="formCreate" v-bind="table"/>

    <el-dialog :visible.sync="dialogVisible" width="60%" :before-close="handleClose">

      <el-descriptions title="用户信息" :column="2" border>
        <el-descriptions-item label="昵称">{{ data.nickname }}</el-descriptions-item>
        <el-descriptions-item label="姓名">{{ data.name }}</el-descriptions-item>
        <el-descriptions-item label="最后登录时间">{{ data.last_login_time_show }}</el-descriptions-item>
        <el-descriptions-item label="余额">{{ data.balance }}</el-descriptions-item>
        <el-descriptions-item label="收入">{{ data.income }}</el-descriptions-item>
        <el-descriptions-item label="积分">{{ data.ji_fen }}</el-descriptions-item>
        <el-descriptions-item label="分享码">{{ data.share_code }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions title="公司信息" :column="2" border style="margin-top: 20px;" v-if="data.userCompany">
        <el-descriptions-item label="公司名称">{{ data.userCompany.company_name }}</el-descriptions-item>
        <el-descriptions-item label="公司类型">{{ data.userCompany.company_type_name }}</el-descriptions-item>
        <el-descriptions-item label="公司状态">{{ data.userCompany.company_status_name }}</el-descriptions-item>
        <el-descriptions-item label="申请时间">{{ data.userCompany.apply_time }}</el-descriptions-item>
        <el-descriptions-item label="审核时间">{{ data.userCompany.audit_time_show }}</el-descriptions-item>
        <el-descriptions-item label="联系人手机">{{ data.userCompany.linkman_mobile }}</el-descriptions-item>
        <el-descriptions-item label="联系人姓名">{{ data.userCompany.linkman_realname }}</el-descriptions-item>
        <el-descriptions-item label="城市">{{ data.userCompany.city_name }}</el-descriptions-item>
        <el-descriptions-item label="经度">{{ data.userCompany.city_long }}</el-descriptions-item>
        <el-descriptions-item label="纬度">{{ data.userCompany.city_lat }}</el-descriptions-item>
        <el-descriptions-item label="案例">{{ data.userCompany.an_li }}</el-descriptions-item>
        <el-descriptions-item label="荣誉">{{ data.userCompany.rong_yu }}</el-descriptions-item>
        <el-descriptions-item label="备注">{{ data.userCompany.note }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions title="扩展信息" :column="1" border style="margin-top: 20px;" v-if="data.userCompany">
        <el-descriptions-item v-for="(item, index) in data.userCompany.ext_content" :key="index"
                              :label="item.lable"
        >
          {{ item.value || '无' }}
        </el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>

</template>

<script>
import renderTable from '@/views/render-table-form'

export default {
  mixins: [renderTable],
  data() {
    return {
      tableFrom: '',
      dialogVisible: false,
      data: {},
      dataCompany: {
        company_name: '',
        company_type_name: '',
        company_status_name: '',
        apply_time: '',
        audit_time_show: '',
        linkman_realname: '',
        city_name: '',
        city_long: '',
        city_lat: '',
        an_li: '',
        rong_yu: '',
        note: '',
        linkman_mobile: '',
        ext_content: [],
        ext_content_show: []
      }
    }
  },
  methods: {
    handleClose() {
      this.dialogVisible = false
    },
    beforeSubmit(row) {
      if (row.form.parent_id instanceof Array) {
        row.form.parent_id = row.form.parent_id.length > 0 ? row.form.parent_id.pop() : 0
      }
      return row
    },

    /**
     * 详情
     * @param e
     */
    viewinfos(e) {
      console.log(e)
      this.$http({
        url: '/WechatUser/read?id=' + e.id,
        method: 'post'
      }).then(r => {
        console.log(r)
        if (r.code == 10000) {
          this.data = r.data
          if (r.data.company_status == 0) {
            this.data.userCompany = this.dataCompany
          }

          setTimeout(() => {
            this.dialogVisible = true
          }, 100)
        }
      })
    }

  }
}
</script>
